<template>
  <!--角色-新增 编辑-->
  <Card class="ll page-fill" style="height:900px">
    <div></div>
    <div style="width:600px;margin:150px auto">
      <Row type="flex" align="middle">
        <Col span="8">意见类型代码:</Col>
        <Col span="14">
        <Input v-model="opinionTypeCode" placeholder="请输入" style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="8">意见类型名称:</Col>
        <Col span="16">
        <Input v-model="opinionTypeName" placeholder="请输入" style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="8">意见类型APP名称:</Col>
        <Col span="16">
        <Input placeholder="请输入" v-model="opinionTypeApp" style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle" style="height:32px">
        <Col span="8">意见分类:</Col>
        <Col span="16">
        <Select v-model="opinionClass" style="width:200px">
          <Option v-for="item in opinionClassDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle" style="height:32px">
        <Col span="8">新增类型所属级别:</Col>
        <Col span="16">
        <Select v-model="opinionLevel" style="width:200px">
          <Option v-for="item in opinionLevelDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle" style="height:32px">
        <Col span="8">父意见类型:</Col>
        <Col span="16">
        <Select v-model="opinionSupCode" style="width:200px">
          <Option v-for="item in opinionSupDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="8">节点代码:</Col>
        <Col span="16">
        <Select v-model="nodeCode" style="width:200px" :disabled="allMark">
          <Option v-for="item in nodeCodeDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="8">节点名称:</Col>
        <Col span="16">
        <Input placeholder="请输入" :disabled="allMark" v-model="nodeName" style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="8">描述:</Col>
        <Col span="16">
        <Input placeholder="请输入" :disabled="allMark" type="textarea" v-model="remark" style="width: 200px"></Input>
        </Col>
      </Row>

      <Row type="flex" align="middle" style="margin-top:20px">
        <Col span="12" style="text-align:center">
        <Button type="primary" @click="handleSubmit" size="small" :disabled="allMark">确认</Button>
        </Col>
        <Col span="12">
        <Button type="primary" size="small">重置</Button>
        </Col>
      </Row>
    </div>
  </Card>
</template>
<script>
export default {
  data () {
    return {
      allMark: false,
      opinionTypeCode: null,
      opinionTypeName: null,
      opinionTypeApp: null,
      opinionClass: 0,
      opinionClassDatas: [
        {
          label: '拒绝',
          value: 0
        },
        {
          label: '违例',
          value: 1
        }
      ],
      opinionSupCode: null,
      opinionSupDatas: [],
      opinionLevel: 1,
      opinionLevelDatas: [
        {
          label: '一级',
          value: 1
        },
        {
          label: '二级',
          value: 2
        },
        {
          label: '三级',
          value: 3
        }
      ],
      nodeCode: null,
      nodeCodeDatas: [],
      nodeName: null,
      remark: null
    }
  },
  computed: {

    type () {
      return this.$route.query.type
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
    this.initFlowCode()
  },
  methods: {
    handleSubmit () {
      var params = {}
      params.opinionTypeCode = this.opinionTypeCode
      params.opinionTypeName = this.opinionTypeName
      params.opinionTypeApp = this.opinionTypeApp
      params.opinionClass = this.opinionClass
      params.opinionLevel = this.opinionLevel
      params.opinionSupCode = this.opinionSupCode
      params.nodeCode = this.nodeCode
      params.nodeName = this.nodeName
      params.remark = this.remark
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/opinion_type/service/add', params)
        .then(re => {
          if (re.data.code === 'success') {
            this.$Message.success('操作成功!')
          } else {
            this.$Message.warning(re.data.data)
          }
        })
        .catch(er => {
          this.$Message.warning('操作失败')
        })
    },
    // 节点选择
    handleNodeSelect (item, index) {
      this.nodeName = item.nodeName
    },
    // 加载流程节点下拉框
    initFlowCode () {
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/flow_node/service/nlist', {})
        .then(re => {
          this.nodeCodesData = []
          var datas = re.data.data.list || []
          datas.forEach(item => {
            var tData = {}
            tData.label = item.nodeName
            tData.value = item.nodeCode
            this.nodeCodeDatas.push(tData)
            this.nodeCode = item.nodeCode
            this.nodeName = item.nodeName
          })
        })
        .catch(er => {
        })
    }
  },
  watch: {
    $route (val) {}
  },
  props: {}
}
</script>

<style lang="less">
.xzqy-page {
  /*@media only screen and (min-width:1366px){
      .bottom-btn button:nth-of-type(1){
        margin-right:70px;
      }
    }
    @media only screen and (min-width:1200px){
      .bottom-btn button:nth-of-type(1){
        margin-right:40px;
      }
    }*/
}
</style>
